package com.ebpm.designer.menu
{
	import com.ebpm.designer.WF;
	import com.ebpm.designer.WP;
	
	import flash.events.MouseEvent;
	
	import mx.collections.ArrayList;
	import mx.containers.Canvas;

	//菜单导航头样式
	public class Menu extends Canvas
	{
		
		public var menus:ArrayList = new ArrayList();
		
		public function Menu(type:String="heng")
		{
			this.setStyle("backgroundColor", "#333333");
			this.setStyle("backgroundAlpha", 0.1);
			var extraH:Number = 0;
			var extraW:Number = 0;
			var startX:Number = 0;
			var startY:Number = 0;
			if(type == "heng") {
				this.y = WF.app.stage.stageHeight - (WF.MENU_ITEM_WIDTH + 10);
				this.height = WF.MENU_ITEM_WIDTH + 10;
				this.width = WF.wp.width;
				extraW = WF.MENU_ITEM_WIDTH + 10;
				startX = (this.width - extraW * 16) / 2;
			} else {
				this.width = WF.MENU_ITEM_WIDTH + 10;
				this.height = WF.wp.height;
				extraH = WF.MENU_ITEM_WIDTH + 10;
				startY = 100;
			}
			
			menus.addItem(new SaveMenu(WF.MenuSave));
			menus.addItem(new OpenMenu(WF.MenuOpen));
			menus.addItem(new ImageCutMenu(WF.MenuImageCut));
			
			menus.addItem(new Canvas());
			
			menus.addItem(new UserTaskMenu(WF.MenuUserTask));
			menus.addItem(new ServiceTaskMenu(WF.MenuServiceTask));
			menus.addItem(new LaneTaskMenu(WF.MenuLaneTask));
			
			menus.addItem(new Canvas());
			
			menus.addItem(new StartEventMenu(WF.MenuStartEvent));
			menus.addItem(new EndEventMenu(WF.MenuEndEvent));
			menus.addItem(new ForkBeforeMenu(WF.MenuForkBefore));
			menus.addItem(new ForkAfterMenu(WF.MenuForkAfter));
			menus.addItem(new LaneBeforeMenu(WF.MenuLaneBefore));
			menus.addItem(new LaneAfterMenu(WF.MenuLaneAfter));
			menus.addItem(new SubStartEventMenu(WF.MenuSubStartEvent));
			menus.addItem(new SubEndEventMenu(WF.MenuSubEndEvent));
			
			for(var i:Number = 0; i<menus.length; i++ ) {
				var item:Canvas = menus.getItemAt(i) as Canvas;
				
				if(i > 0) {
					var before:Canvas = menus.getItemAt(i-1) as Canvas;
					if(before is MenuItem) {
						if(type == "heng") {
							item.x = before.x + before.width;
						} else {
							item.y = before.y + before.height;
						}
					} else {
						if(type == "heng") {
							item.x = before.x + 30;
						} else {
							item.y = before.y + 30;
						}
					}
				} else {
					item.x = startX;
					item.y = startY;
				}
				this.addElement(item);
			}
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDown);
			
		}
		
		public function _mouseDown(event:MouseEvent):void {
			WP.isAllowSelectNodeContainers = false;
		}
		
	
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
}